import _ from 'lodash'
export const initField = (component) => {
  if (!_.isNil(component)) {
    let type = component.name
    if (!_.isNil(type)) {
      switch (type) {
        case 'select':
          component.clearable = true
          break
        case 'select-multiple':
          component.clearable = true
          component.multiple = true
          break
        case 'input': break
        case 'percentageInput': break
        case 'radio': break
        case 'checkbox': break
        case 'date':
          component.size = 'mini'
          component.type = 'date'
          component.format = 'yyyy/MM/dd'
          component['value-format'] = 'timestamp'
          component.clearable = false
          break
        case 'date-range':
          component.type = 'daterange'
          component['range-separator'] = '至'
          component['start-placeholder'] = '开始日期'
          component['end-placeholder'] = '结束日期'
          break
        case 'color': break
        case 'textarea':
          component.type = 'textarea'
          break
        case 'tag':
          component.type = 'info'
          break
        case 'transfer': break
        case 'upload': break
        case 'switch':
          component['active-color'] = '#13ce66'
          component['inactive-color'] = '#ccc'
          break
        case 'slider': break
        case 'image': break
        case 'password': component.type = 'password'; break
        case 'input-number':
          break
        case 'treeselect':
          component.clearable = true
          break
      }
    }
  }
}

export const getFieldType = (component) => {
  let result = 'el-input'
  if (!_.isNil(component)) {
    let type = component.name
    if (!_.isNil(type)) {
      switch (type) {
        case 'select': result = 'el-select'; break
        case 'select-multiple': result = 'el-select'; break
        case 'input': result = 'el-input'; break
        case 'percentageInput': result = 'el-input'; break
        case 'radio': result = 'el-radio'; break
        case 'checkbox': result = 'el-checkbox'; break
        case 'date': result = 'el-date-picker'; break
        case 'date-range': result = 'el-date-picker'; break
        case 'color': result = 'el-color-picker'; break
        case 'textarea': result = 'el-input'; break
        case 'tag': result = 'el-tag'; break
        case 'transfer': result = 'el-transfer'; break
        case 'switch': result = 'el-switch'; break
        case 'slider': result = 'el-slider'; break
        case 'image': result = 'el-image'; break
        case 'password': result = 'el-input'; break
        case 'button': result = 'el-button'; break
        case 'button-group': result = 'el-button-group'; break
        case 'radio-group': result = 'el-radio-group'; break
        case 'treeselect': result = 'treeselect'; break
        case 'dict-select': result = 'yc-dict-select'; break
        case 'dict-radio': result = 'yc-dict-radio'; break
        case 'icon-select': result = 'yc-icon-select'; break
        case 'input-number': result = 'el-input-number'; break
        case 'upload-avatar': result = 'yc-upload-avatar'; break
        case 'upload-file': result = 'yc-upload-file'; break
        case 'upload-file-single': result = 'yc-upload-file-single'; break
        case 'upload-file-multiple': result = 'yc-upload-file-multiple'; break
        case 'cascader': result = 'yc-cascader'; break
        case 'ueditor': result = 'yc-ueditor'; break
        case 'tag-dynamic': result = 'yc-tag-dynamic'; break
      }
    }
  }
  return result
}

export const isButton = (name) => {
  return name === 'button'
}

export const isSelect = (name) => {
  return name === 'select'
}

export const isMultipleSelect = (name) => {
  return name === 'select-multiple'
}

export const isDate = (name) => {
  return name === 'date'
}

export const isPercentageInput = (name) => {
  return name === 'percentageInput'
}

export const isButtonGroup = (name) => {
  return name === 'button-group'
}

export const isRadioGroup = (name) => {
  return name === 'radio-group'
}
